<?php
/**
 * Created by PhpStorm.
 * User: 35083
 * Date: 2019/7/5
 * Time: 10:34
 */

namespace app\admin\mapper;


class Pushmsg
{
    static private $instance = null;
    public $funLists = array();


    static public function getInstance()
    {
        //判断$instance是否是Uni的对象
        //没有则创建
        if (self::$instance == null) {
            self::$instance = new self();
        }
        return self::$instance;

    }

    /**
     * @return array
     */
    public function getFunLists()
    {
        return $this->funLists;
    }

    /**
     * @param array $funLists
     */
    public function setFunLists($funLists)
    {
        $this->funLists = $funLists;
    }

    public function funMapper($ty)
    {
        $string = "";
        $lists = $this->getFunLists();
        foreach ($lists as $key => $val) {
            if ($ty == $key) {
                $string = $val;
                break;
            }
        }

        return $string;
    }


    public function statsMapper($ty)
    {
        $string = "";
        if ($ty == '0') {
            $string = "<font>待推送</font>";
        } else if ($ty == '1') {
            $string = "<font>已推送</font>";
        }
        return $string;
    }
    public function pushTimeTypeMapper($ty)
    {
        $string = "";
        if ($ty == '0') {
            $string = "<font>立即推送</font>";
        } else if ($ty == '1') {
            $string = "<font>定时推送</font>";
        }
        else if ($ty == '2') {
            $string = "<font>循环推送</font>";
        }
        return $string;
    }

    public function listMapper($list)
    {
        foreach ($list as $key => $val) {
            $list[$key] = $this->infoMapper($val);
        }
        return $list;
    }

    public function infoMapper($info)
    {
        $info['statsMapper'] = $this->statsMapper($info['stats']);
        $info['funMapper'] = $this->funMapper($info['optype']);
        $info['pushTimeTypeMapper'] = $this->pushTimeTypeMapper($info['push_time_type']);
        return $info;
    }
}